package com.longshine.arthmetic;

import javax.swing.JFrame;

/**
 * 树结点类
 *  
 *
 * @classname   Node.java 
 * @author      YitianC
 * @version     Revision: 1.1,  Date: 2008/05/14 01:43:47  
 * @history     
 *              Mar 13, 2012 4:54:35 PM  
 *
 */
public class Node extends NodeDrawable{
	/**
	 * 在画结点方法中加入画线条功能
	 * 
	 *
	 * @param container 
	 * 
	 * @Overriding  重载方法
	 */
	@Override
	public void draw(JFrame container) {
		super.draw(container);
		if(parent == null) return;
		container.getContentPane().getGraphics().drawLine(parent.getX(), parent.getY(), x, y);
	}

	public Node left; //左结点
	public Node parent; //父结点
	public Node right;  //右结点
	public Node(int weight,Node l,Node p,Node r){
		this.left = l;
		this.parent = p;
		this.right =r;
		this.weight = weight;
	}
	/**
	 * 
	 * @Description  @param weight 权重
	 *
	 * @Constructors 构造函数
	 */
	public Node (int weight){
		this.weight = weight;
	}
	public String toString(){
		return this.weight+"";
	}
	
	public boolean equals(Node n){
		return weight==n.weight&&parent==n.parent&&left == n.left&&right==n.right;
	}
}
